<html>
<head><meta charset="utf-8"><title>git pre-push hook · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html">git pre-push hook</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247264877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/git%20pre-push%20hook/near/247264877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html#247264877">(Jul 26 2021 at 21:18)</a>:</h4>
<p>Just mentioning that if you forget to run <code>x fmt</code> before pushing up your changes, you may find it useful to add a git pre-push hook that will run <code>x fmt --check</code>. To do so, add an executable file called <code>pre-push</code> to <code>.git/hooks</code> in your rust-lang/rust clone(s) with this content:</p>
<div class="codehilite" data-code-language="Bash"><pre><span></span><code>x fmt --check
</code></pre></div>
<p>(You'll have to install the in-tree <code>src/tools/x</code> tool for this to work, which is very useful by itself too.)</p>



<a name="247264967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/git%20pre-push%20hook/near/247264967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html#247264967">(Jul 26 2021 at 21:19)</a>:</h4>
<p>The one downside is that pushes will take a bit longer (5 seconds longer, on my machine), but it may save time if you otherwise end up having to format and repush.</p>



<a name="247273540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/git%20pre-push%20hook/near/247273540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html#247273540">(Jul 26 2021 at 22:45)</a>:</h4>
<p>Or you can run a full <code>tidy</code></p>



<a name="247278165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/git%20pre-push%20hook/near/247278165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html#247278165">(Jul 26 2021 at 23:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="255061">Léo Lanteri Thauvin</span> <a href="#narrow/stream/266220-rustdoc/topic/git.20pre-push.20hook/near/247273540">said</a>:</p>
<blockquote>
<p>Or you can run a full <code>tidy</code></p>
</blockquote>
<p>True, but that would take longer, and in my experience, most of the time the formatting is the only part that needs to be fixed.</p>



<a name="247305946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/git%20pre-push%20hook/near/247305946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html#247305946">(Jul 27 2021 at 08:19)</a>:</h4>
<p>Please don't add git hooks. Especially on the rust compiler...</p>



<a name="247309493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/git%20pre-push%20hook/near/247309493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html#247309493">(Jul 27 2021 at 09:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="307537">Noah Lev</span> <a href="#narrow/stream/266220-rustdoc/topic/git.20pre-push.20hook/near/247264967">said</a>:</p>
<blockquote>
<p>The one downside is that pushes will take a bit longer (5 seconds longer, on my machine), but it may save time if you otherwise end up having to format and repush.</p>
</blockquote>
<p>Personally, I usually have my editor format files on save, so when I know that everything is already formatted I run git with <code>--no-verify</code></p>



<a name="247321231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/git%20pre-push%20hook/near/247321231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html#247321231">(Jul 27 2021 at 11:34)</a>:</h4>
<p><span class="user-mention" data-user-id="210316">@GuillaumeGomez</span> you can configure hooks for yourself without adding them for everyone, I think that's what <span class="user-mention" data-user-id="307537">@Noah Lev</span> is suggesting. x.py setup actually suggests installing a git hook but I suspect most of the people on the team added a config.toml before it started doing that and won't have seen the prompt.</p>



<a name="247321855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/git%20pre-push%20hook/near/247321855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html#247321855">(Jul 27 2021 at 11:42)</a>:</h4>
<p>Phew. I feel relieved</p>



<a name="247393557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/git%20pre-push%20hook/near/247393557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/git.20pre-push.20hook.html#247393557">(Jul 27 2021 at 21:21)</a>:</h4>
<p>Yeah, AIUI git hooks are fully local-only :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>